//
//  THJOtherDataCell.m
//  THJXHW
//
//  Created by 河南德艺 on 2017/11/20.
//  Copyright © 2017年 河南德艺. All rights reserved.
//

#import "THJOtherDataCell.h"
#import "UIButton+ImageTitleSpacing.h"

@implementation THJOtherDataCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}
-(void)setContentWithArr:(NSArray*)arr{
    CGFloat btnWidth = ScreenWidth/4;
    for(NSInteger i = 0;i<arr.count;i++){
        NSDictionary * dic = arr[i];
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        NSInteger row = i/4;
        NSInteger col = i%4;
        [btn setImage:[UIImage imageNamed:@"圆"] forState:UIControlStateNormal];
        btn.titleLabel.font = [UIFont systemFontOfSize:12];
        btn.tag = [dic[@"id"] integerValue];
        [btn setTitle:dic[@"name"] forState:UIControlStateNormal];
        btn.frame = CGRectMake(col*btnWidth, row*btnWidth, btnWidth, btnWidth);
        btn.backgroundColor = SingleColor(clearColor);
        [btn sd_setButtonImageWithUrl:dic[@"url"] placeHolderImgWithName:@"圆"];
        NSLog(@"dicurl-%@",arr);
        [btn addTarget:self action:@selector(btnclicked:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:btn];
    }
}
-(void)btnclicked:(UIButton*)btn{
    [self.delegate btnClickWithID:btn.tag];
}
@end
